<template>
  <el-dialog :visible.sync="visible" custom-class="dialog_big" width="50%" @close="resetForm" >
    <div slot="title" class="flex_row-jcsb">
      <slot name="title">
        <span class="el-dialog__title">预约调整</span>
      </slot>
    </div>
    <el-form :model="formData" :rules="rules" ref="ruleForm" label-width="130px">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="审核" prop="checkStatus">
            <el-select v-model="formData.checkStatus" disabled style="width: 100%;" placeholder="请选择审核状态">
              <el-option v-for="(item,index) in $enumOptions.ScheduleCheckStatusEnum" :key="index" :label="$t('ScheduleCheckStatusEnum__'+item)" :value="item"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="调整到仓时间" prop="expectedDatetime">
            <el-date-picker
              v-model="formData.expectedDatetime"
              type="datetime"
              placeholder="选择日期时间"
              value-format="timestamp"
              :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户名称">
            <el-input v-model="formData.customerName"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="运单编号">
            <el-input v-model="formData.transitNo"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="入库单号">
            <el-input v-model="formData.receivingOrderCodeList"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="车牌号码">
            <el-input v-model="formData.vehicleNo"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="司机姓名">
            <el-input v-model="formData.driverName"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="司机电话">
            <el-input v-model="formData.driverPhone"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="申报箱数">
            <el-input v-model="formData.expectPackagingQty"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="申报包数">
            <el-input v-model="formData.expectBoxQty"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="申报货物重量">
            <el-input v-model="formData.weight"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="申报货物体积">
            <el-input v-model="formData.volumn"  disabled ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="预计到仓时间">
            <el-date-picker
              v-model="formData.expectedDate"
              type="datetime"
              disabled
              placeholder="选择日期时间"
              value-format="timestamp"
              :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <div slot="footer" class="dialog_button_footer">
        <el-button type="primary" @click="submitForm">{{ $tt('label_confirm') }}</el-button>
        <el-button @click="resetForm">{{ $tt('label_cancel') }}</el-button>
      </div>
</el-dialog>
</template>

<script>

export default {
  name: 'settings',
  data() {
    return {
      visible: false,
      loading: false,
      currentDate:'',
      warehouseList:[],
      inWarehouseList:[],
      formData:{
      },
      rules:{
        expectedDatetime:[{ required: true, message: '请选择调整到仓时间', trigger: 'change' }],
      },
      pickerOptions: {
        disabledDate(time) {
            return time.getTime() < Date.now() - 8.64e7;
        }
      }
    }
  },
  mounted() {

  },
  methods: {
    show(row) {
      this.visible = true
      this.formData = row
      this.formData.receivingOrderCodeList=row.receivingOrderCodeList.toString()
      this.formData.scheduleId = row.id
      this.formData.checkStatus = 'APPROVED'

    },
    hide() {
      this.visible = false
    },
    submitForm() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {

          this.$ajax({
            url:'/wms-api/inbound/WmsInboundScheduleRpc/adjust.json',
            method: 'post',
            data:this.formData,
            type: "json",
            loading: true,
            success: (res) => {
              this.$emitPage('warehouse_appointment>confirm', 'reload')
              this.resetForm()
              this.$message.success(this.$tt("tip_submit_success"))
            }
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm() {
      this.$refs['ruleForm'].resetFields();
      this.$data.formData = this.$options.data().formData
      this.visible=false;
    },
  }
}
</script>

<style lang="less" scoped>
.newDate{
  float: right;
  margin-right: 40px;
}
.el-select{
  display: block;
}
</style>
